import { _decorator, Component, Node, Prefab, instantiate, UITransform } from 'cc';
const { ccclass, property } = _decorator;
import methods from "db://assets/common/methods";

@ccclass('index')
export class index extends Component {
    @property(Prefab)
    zi_wei: Prefab = null
    @property(Prefab)
    shen_sheng: Prefab = null
    @property(Prefab)
    zhen_hong: Prefab = null
    @property(Prefab)
    list_bg: Prefab = null

    arms_Node: Map<string, Node> = new Map()
    list_bg_Node: Map<string, Node> = new Map()

    start() {
        for(let i = 1; i < 11   ; i++) {
            let uuid = methods.getUUID()
            this.list_bg_Node.set(uuid, instantiate(this.list_bg))
            this.list_bg_Node.get(uuid).getComponent(UITransform).setContentSize(this.node.getComponent(UITransform).width - 60, 80)
            this.list_bg_Node.get(uuid).y = -((this.list_bg_Node.get(uuid).getComponent(UITransform).height) * i + i * 20)
            this.list_bg_Node.get(uuid).x = 0
            this.list_bg_Node.get(uuid).setParent(this.node);
            let uuid2 = methods.getUUID()
            if(i % 3 == 0) {
                this.arms_Node.set(uuid2, instantiate(this.zi_wei))
            }else if(i % 3 == 1) {
                this.arms_Node.set(uuid2, instantiate(this.shen_sheng))
            }else {
                this.arms_Node.set(uuid2, instantiate(this.zhen_hong))
            }
            this.arms_Node.get(uuid2).setParent(this.list_bg_Node.get(uuid))
            this.arms_Node.get(uuid2).x = 0
            this.arms_Node.get(uuid2).y = 0
        }
        this.node.getComponent(UITransform).height = 100 * 11
    }

    update(deltaTime: number) {
        
    }
}


